package com.gw.mapper;

import com.gw.pojo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    /**
     * 根据邮箱查询用户
     * @param email
     * @return
     */
    @Select("select * from user where email = #{email};")
    User getByEmail(String email);

    /**
     * 用户注册
     * @param user
     */
    @Insert("insert into user " +
            "(avatar, nickname, email, password, name," +
            " phone, grades, student_id, identity, create_time) " +
            "values " +
            "(#{avatar}, #{nickname}, #{email}, #{password}, #{name}," +
            " #{phone}, #{grades}, #{studentId}, #{identity}, #{createTime})")
    void addUser(User user);

    /**
     * 修改用户信息
     * @param user
     */
    void updateUser(User user);
}
